
const filterSpecialChar = function(Vue) {
  Vue.directive('filterSpecialChar', function(el, { value, modifiers }, vnode) {
    try {
      if (value !== null) {
        const newval = value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\-\\/_]/g, '')
        if (value !== newval) {
          el.children[0].value = newval
          el.children[0].dispatchEvent(new Event(modifiers.lazy ? 'change' : 'input'))
        }
      }
    } catch (e) {
      console.log(e)
    }
  })
}

export default filterSpecialChar
